#include <iostream>

using namespace std;

struct ListNode
{
    int val;
    ListNode *next;
    ListNode(int x) : val(x), next(NULL) {}
};

void insertTailList(ListNode *head, int val)
{
    while (head->next) //走到链表的末尾来插入
        head = head->next;

    ListNode *cur = new ListNode(-1);
    cur->val = val;
    head->next = cur;
    cur->next = NULL;
}

int lenList(ListNode *head)
{
    int len = 0;
    head = head->next;
    while (head)
    {
        len++;
        head = head->next;
    }
    return len;
}

int kthToLast(ListNode *head, int k)
{
    int ret;
    int len = lenList(head);
    int n = len - k + 1;

    while (n--)
    {
        head = head->next;
        if (n == 0)
            return head->val;
    }

    return ret;
}

int main()
{
    ListNode *head;

    int arr[] = {13, 1222};
    int n = sizeof(arr) / sizeof(arr[0]);

    for (int i = 0; i < n; i++)
    {
        insertTailList(head, arr[i]);
    }

    int k;
    cin >> k; //第k大
    //----------------------------------------
    int kthNode = kthToLast(head, k);
    cout << kthNode << endl;
    return 0;
}
